The present invention relates to a method for converting a source program having a loop including a control statement and a plurality of statements to be repetitiously executed into an object program.
Source programs include so-called loops in many cases, each loop containing a plurality of statements to be repetitiously executed. Since the loop is subjected to an iterative execution, most of the time required for an execution of an object program is allocated to an object program generated corresponding to the loop. Among the code optimization techniques heretofore developed to reduce the execution time of an object program, most of these techniques are implemented by paying attention to the loop.
The "Supercomputer HITAC S-810 FORTRAN COMPILER, VO S3 FORT 77/HAP", Hitachi Hyoron, Vol. 65, No. 8, pp. 551-555, (1983) or "A Vectorization Algorithm for Control Statement", Journal of Information Processing, Vol. 7, No. 3, pp. 170-174, (1984) describes a method for converting the loop structure in which two kinds of statements, i.e. the loop invariant control statement (for which a result is predetermined independently of the iteration of the loop) and the loop starting-point control statement (for which the judgment of the initial execution of the loop is reversed with respect to that of the subsequent execution of the loop) from the control statements in a loop, thereby obtaining the same results for the loops before and after the conversion. A loop expansion method applied to a case of a loop starting-point control statement will be described with reference to FIG. 2.
In FIG. 2, reference numeral 700 denotes an example of a FORTRAN program including the starting-point control statement, which is indicated by .circle.1 Examining the characteristic of the condition IF (I. EQ. 1) in the control statement .circle.1 , the variable I is used to control the loop iteration count, namely, the condition is satisfied at the starting point (I=1) of the loop and the condition is not satisfied at other iterations.
If the portions .circle.2 , .circle.3 , and .circle.4 to be initially (I=1) executed in the iteration of the loop are moved to locations outside the loop so as to achieve the loop iteration beginning from the second execution (I=2) the control statement in the loop becomes to be permanently false, which enables to unnecessitate the control statement and hence to remove the control statement .circle.1 , the executable statement .circle.5 when the condition is satisfied, the ELSE statement, and the END statement. The result of the conversion accomplished on the loop structure becomes to be as shown in a program 702 of FIG. 2.
As methods for converting the loop structure to solve the problem associated with the control statement, there have only been known the methods described in the above-mentioned paper for effecting the conversion on the two kinds of control statements (i.e. the loop starting-point control statement and the loop invariant control statement), namely, other kinds of control statements have not been discussed with respect to the loop structure conversion.
As described above, among the control statements in a loop, only the limited kinds of control statements can be processed to solve the problems associated therewith.